<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>用户筛选器列表</title>
</head>
<body>

<div class="container">

        <div class="comm_content">

            <div class="search-box">
                <div style="position:relative">
                    <form id="searchForm" onsubmit="return false;" class="form-inline">

                        <span>
                            选择器ID：<input type="text" id="selectID" class="form-control w150" name="selectID" value="" />
                        </span>

                        <span>
                            选择器名称：<input type="text" id="selectDisplayName" class="form-control w150" name="selectDisplayName" value="" />
                        </span>

                        <span><input type="button" value="查询" class="btn btn-primary" onclick="selector.search();" /></span>
                        <span><input type="button" class="btn btn-warning" value="重置" onclick="selector.clear();"></span>


                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>

        </div>

</div>

<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/promotion/userSelector.ajax?operFlg=1",
        dataType: "json",
        colModel : [
            {display: "操作", width : 120, align: "center"},
            {display: "选择器ID", width : 90, align: "left", name : "selectID", sortable : true},
            {display: "选择器名称", width : 310},
            {display: "描述", width : 310}
        ],
        buttons : [
            {name: "添加", bclass: "add", onpress : "selector.add"},
            {separator: true},
            {name: "删除", bclass: "delete", onpress : "selector.deleteSelector"},
            {separator: true},
            {name: "全选", bclass: "checkAll", onpress : "E.checkAllList"},
            {separator: true},
            {name: "取消全选", bclass: "cancelCheckAll", onpress : "E.cancelCheckAllList"}
        ],
        sortname: "selectID",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
    });

    var selector = {

        delete_str: "" ,
        useFlg_str : "" ,

        //搜索筛选器
        search: function() {
            var dt = $('#searchForm').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },

        //打开折叠表格
        openList: function (selectID){
            //生成传入参数


            var dt = $('#searchForm').serializeArray();
            dt.push({ 'name':'detailID','value':selectID});
            //刷新页面
            $("#flex").flexOptions({params: dt}).flexReload();
        },



        //关上折叠表格
        closeList: function (){
            var dt = $('#searchForm').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },

        //添加筛选器
        add: function() {
            E.open("/quanliadmin/app/promotion/userSelector.pscript?operFlg=2", "", {height: 600,width: 1024, top: 50, left: 150});
        },

        deleteSelector: function() {
            this.delete_str = "";
            $.each($("#flex").find("tr"), function(k, v) {
                if ($(v).hasClass("trSelected")) {
                    if($(v).attr("id") != undefined)
                        selector.delete_str += "|" + $(v).attr("id").replace("row", "");
                }
            });

            if (this.delete_str == "")
                E.alert("请选择删除的筛选器");
            else
                E.confirm("您确认要删除选中的筛选器吗？", "selector.deleteConfirm");
        },

        deleteConfirm: function() {
            this.delete_str = this.delete_str.substr(1);
            var delete_obj = {delete_str : selector.delete_str};

            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/promotion/userSelector.ajax?operFlg=3",
                dataType: "JSON",
                data: delete_obj,
                success: function( result_obj ) {
                    if (result_obj.code == 200)
                        E.alert(result_obj.message, 2, "selector.load");
                    else
                        E.alert(result_obj.message);
                }
            });
        },

        edit: function(selectorID) {
            E.open("/quanliadmin/app/promotion/userSelector.pscript?operFlg=3&selectorID=" + selectorID, "", {height: 600,width: 1024, top: 50, left: 150});
        },

        //查看用户筛选器详情
        view : function(selectID){
            E.open("/quanliadmin/app/promotion/userSelector.pscript?operFlg=4&selectID="+selectID, "", {height: 600,width: 1024, top: 50, left: 150});
        },

        //重置表单
        clear: function() {
            document.forms['searchForm'].reset();
            this.search();
        },

        load: function() {
            $("#flex").flexReload();
        }

    };
</script>

</body>
</html>